furny.ga
Class FurnLayoutIndividual

java.lang.Object
  extended by furny.ga.FurnLayoutIndividual
All Implemented Interfaces:
IClusterableIndividual<FurnLayoutIndividual>, ICostInfo, IDebugInfo, IFitness, IIndividual<FurnLayoutIndividual>, IIntervalFitness, java.lang.Cloneable, org.apache.commons.math.stat.clustering.Clusterable<FurnLayoutIndividual>

public final class FurnLayoutIndividual
extends java.lang.Object
implements IClusterableIndividual<FurnLayoutIndividual>, IIntervalFitness, IDebugInfo, ICostInfo

Individual for furniture layouts. This supports clustering, interval fitness, cost info output and debug infos.

Since:
11.08.2012
Author:
Stephan Dreyer

Field Summary
private  GAContext context
          The GA context is always required.
private  double fitnessCenter
           
private  double fitnessMax
           
private  double fitnessMin
           
private  FurnEntryList furnitures
          List of furniture entries.
private  long id
           
private static java.util.concurrent.atomic.AtomicLong ID_GENERATOR
          Generator for unique ids.
private static java.util.Random rnd
           
 
Fields inherited from interface ga.core.individual.IFitness
UNEVALUATED
 
Constructor Summary
FurnLayoutIndividual()
          Creates a new individual.
FurnLayoutIndividual(GAContext context)
          Creates a new individual using the given context.
 
Method Summary
 FurnLayoutIndividual centroidOf(java.util.Collection<FurnLayoutIndividual> c)
           
 FurnLayoutIndividual clone()
          Creates a new individual that is equal to this.
 double distanceFrom(FurnLayoutIndividual ind2)
          Calculates the distance from this individual to the second individual, normalized to [0;1].
 boolean equals(java.lang.Object obj)
           
 GAContext getContext()
          Getter for the GA context.
 double getCosts()
          Get the costs as double.
 java.lang.String getCostString()
          Get the textual representation of the costs.
 java.lang.String getDebugString()
          Get the debug string of the individual.
 double getFitness()
          Getter for the fitness of the individual.
 double getFitnessWidth()
          Getter for the fitness width (max-min).
 FurnEntryList getFurnitures()
          Getter for the genotype of the individual.
 java.lang.String getGenotypeString()
          Get a string representation of the genotype.
 long getId()
          Getter for the unique id.
 java.lang.String getIdString()
          Get a string of the id.
 double getMaxFitness()
          Getter for the maximum fitness.
 double getMinFitness()
          Getter for the minimum fitness.
 long[][] getSimpleGenotype()
          Getter for the simple genotype.
 int hashCode()
           
 void initRandomly()
          Initializes the genotype randomly and resets the fitness.
 boolean isEvaluated()
          Determines if the individual has been evaluated.
 void setContext(GAContext context)
          Sets the GA context.
 void setFitness(double fitness)
          Setter for the fitness of the individual.
 void setFitnessInterval(double center, double width)
          Sets the fitness interval by its center and width.
 void setFitnessLimits(double min, double max)
          Sets the fitness interval by its minimum and maximum.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

rnd

private static java.util.Random rnd

ID_GENERATOR

private static final java.util.concurrent.atomic.AtomicLong ID_GENERATOR
Generator for unique ids.


id

private final long id

furnitures

private final FurnEntryList furnitures
List of furniture entries. This is the genotype of the individual.


fitnessCenter

private double fitnessCenter

fitnessMin

private double fitnessMin

fitnessMax

private double fitnessMax

context

private GAContext context
The GA context is always required.

Constructor Detail

FurnLayoutIndividual

public FurnLayoutIndividual(GAContext context)
Creates a new individual using the given context. It will have a unique id.

Parameters:
context - The GA context.
Since:
11.08.2012

FurnLayoutIndividual

public FurnLayoutIndividual()
Creates a new individual. It will have a unique id. The GA context must be set later.

Since:
11.08.2012
Method Detail

setContext

public void setContext(GAContext context)
Description copied from interface: IIndividual
Sets the GA context.

Specified by:
setContext in interface IIndividual<FurnLayoutIndividual>
Parameters:
context - The context

getContext

public GAContext getContext()
Description copied from interface: IIndividual
Getter for the GA context.

Specified by:
getContext in interface IIndividual<FurnLayoutIndividual>
Returns:
context The context

getId

public long getId()
Description copied from interface: IIndividual
Getter for the unique id.

Specified by:
getId in interface IIndividual<FurnLayoutIndividual>
Returns:
The id.

setFitness

public void setFitness(double fitness)
Description copied from interface: IFitness
Setter for the fitness of the individual.

Specified by:
setFitness in interface IFitness
Parameters:
fitness - The fitness.

getFitness

public double getFitness()
Description copied from interface: IFitness
Getter for the fitness of the individual.

Specified by:
getFitness in interface IFitness
Returns:
The fitness.

getMaxFitness

public double getMaxFitness()
Description copied from interface: IIntervalFitness
Getter for the maximum fitness.

Specified by:
getMaxFitness in interface IIntervalFitness
Returns:
The max fitness.

getMinFitness

public double getMinFitness()
Description copied from interface: IIntervalFitness
Getter for the minimum fitness.

Specified by:
getMinFitness in interface IIntervalFitness
Returns:
The min fitness.

getFitnessWidth

public double getFitnessWidth()
Description copied from interface: IIntervalFitness
Getter for the fitness width (max-min).

Specified by:
getFitnessWidth in interface IIntervalFitness
Returns:
The width.

setFitnessInterval

public void setFitnessInterval(double center,
                               double width)
Description copied from interface: IIntervalFitness
Sets the fitness interval by its center and width.

Specified by:
setFitnessInterval in interface IIntervalFitness
Parameters:
center - Center of the fitness interval.
width - The width of the fitness interval.

setFitnessLimits

public void setFitnessLimits(double min,
                             double max)
Description copied from interface: IIntervalFitness
Sets the fitness interval by its minimum and maximum.

Specified by:
setFitnessLimits in interface IIntervalFitness
Parameters:
min - Minimum fitness.
max - Maximum fitness.

initRandomly

public void initRandomly()
Description copied from interface: IIndividual
Initializes the genotype randomly and resets the fitness.

Specified by:
initRandomly in interface IIndividual<FurnLayoutIndividual>

getFurnitures

public FurnEntryList getFurnitures()
Getter for the genotype of the individual.

Returns:
The list of furniture entries.
Since:
11.08.2012

getSimpleGenotype

public long[][] getSimpleGenotype()
Getter for the simple genotype. This is just an array of long numbers.

Returns:
The simple genotype.
Since:
11.08.2012

isEvaluated

public boolean isEvaluated()
Description copied from interface: IIndividual
Determines if the individual has been evaluated.

Specified by:
isEvaluated in interface IIndividual<FurnLayoutIndividual>
Returns:
true if the individual is evaluated.

clone

public FurnLayoutIndividual clone()
Description copied from interface: IIndividual
Creates a new individual that is equal to this.

Specified by:
clone in interface IIndividual<FurnLayoutIndividual>
Overrides:
clone in class java.lang.Object
Returns:
The clone.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getDebugString

public java.lang.String getDebugString()
Description copied from interface: IDebugInfo
Get the debug string of the individual. This is usually the genotyp and the fitness.

Specified by:
getDebugString in interface IDebugInfo
Returns:
Debug string.

getIdString

public java.lang.String getIdString()
Description copied from interface: IDebugInfo
Get a string of the id.

Specified by:
getIdString in interface IDebugInfo
Returns:
Id as string.

getCosts

public double getCosts()
Description copied from interface: ICostInfo
Get the costs as double.

Specified by:
getCosts in interface ICostInfo
Returns:
Costs.

getCostString

public java.lang.String getCostString()
Description copied from interface: ICostInfo
Get the textual representation of the costs.

Specified by:
getCostString in interface ICostInfo
Returns:
Costs string.

getGenotypeString

public java.lang.String getGenotypeString()
Description copied from interface: IDebugInfo
Get a string representation of the genotype.

Specified by:
getGenotypeString in interface IDebugInfo
Returns:
Genotype string.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

centroidOf

public FurnLayoutIndividual centroidOf(java.util.Collection<FurnLayoutIndividual> c)
Specified by:
centroidOf in interface org.apache.commons.math.stat.clustering.Clusterable<FurnLayoutIndividual>

distanceFrom

public double distanceFrom(FurnLayoutIndividual ind2)
Description copied from interface: IClusterableIndividual
Calculates the distance from this individual to the second individual, normalized to [0;1].

Specified by:
distanceFrom in interface IClusterableIndividual<FurnLayoutIndividual>
Specified by:
distanceFrom in interface org.apache.commons.math.stat.clustering.Clusterable<FurnLayoutIndividual>
Parameters:
ind2 - The second individual
Returns:
Normalized distance of this individual from the second individual.